﻿
using System ;
using System.Windows.Forms ;

using MskEdit.Dxf.Model ;


namespace MskEdit.Dxf.Frontend
{

    public class DxfClassesTreeNode : TreeNode 
    {
        private DxfClasses dxfClasses_ ;
        
        
        public static DxfClassesTreeNode TryFrom( DxfClasses dxfClasses, DxfClassesTreeNode fallbackValue ) {
        
            if ( dxfClasses == null )
                return fallbackValue ;
                
            return new DxfClassesTreeNode( dxfClasses ) ;
        }
        
        
        public DxfClassesTreeNode( DxfClasses dxfClasses ) {
        
            dxfClasses_ = dxfClasses ;
            this.Text = "Classes " ;
                
            foreach ( var dxfClass in dxfClasses_.Classes ) {
                
                DxfClassTreeNode dxfClassTreeNode = DxfClassTreeNode.TryFrom( dxfClass, null ) ;
                if ( dxfClassTreeNode == null )
                    continue ;
                    
                this.Nodes.Add( dxfClassTreeNode ) ;
            }
            
        }
    }
}
